<aside id="left-menus" class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="index" class="brand-link">
        <img src="/adminlte/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
             style="opacity: .8">
        <span class="brand-text font-weight-light">博客系统</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
        <!-- Sidebar user panel (optional) -->
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <img src="/adminlte/dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
            </div>
            <div class="info">
                <a href="#" id="nickName" class="d-block">{{nickName}}</a>
            </div>
        </div>

        <!-- Sidebar Menu -->
        <!-- 此处只处理两层结构 -->
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
                <li class="nav-item has-treeview menu-open" v-for="menu in menus">
                    <a class="nav-link">
                        <p>
                            {{menu.menuName}}
                            <i class="right fas fa-angle-left" v-if="menu.subMenus!=null"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview" v-if="menu.subMenus!=null">
                        <li class="nav-item has-treeview menu-open" v-for="subMenu in menu.subMenus">
                            <a :href='subMenu.url' class="nav-link" style="padding-left: 20px">
                                <p>
                                    {{subMenu.menuName}}
                                </p>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </nav>
        <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
</aside>

<script src="https://www.jq22.com/jquery/vue.min.js"></script>
<script>
    let vue = new Vue({
        el:'#left-menus',
        data: {
            nickName: '',
            menus: new Array()
        }
    });
    //设置用户昵称
    $(document).ready(function() {
        let nickName = JSON.parse(localStorage.getItem("userSession")).nickName;
        let userName = JSON.parse(localStorage.getItem("userSession")).userName;
        if(nickName == null || typeof(nickName) == undefined) {
            vue.nickName = userName;
        }else {
            vue.nickName = nickName;
        }
        vue.menus = JSON.parse(localStorage.getItem("userSession")).menus;
    })
</script>
